import matplotlib.pyplot as plt
import pandas, matplotlib
from matplotlib import pyplot

# 读取excel文件
df = pandas.read_excel("景区天气.xlsx")
print(df)
# 解决中文乱码
pyplot.rcParams['font.sans-serif'] = ['SimHei']
# 设置画布大小
plt.figure(figsize=(10, 6))
labels = df["景区"]  # 取景区这一列
print(labels)
y = df["旅游指数"]
print(y)
# 绘制饼图
pyplot.pie(y, labels=labels, autopct='%1.1f%%', startangle=90)
# 设置x y轴
pyplot.axis('equal')
pyplot.title('各景区旅游指数饼状图')
pyplot.show()
